package com.fsnmt.maizhuanbao.utils;

import android.text.TextUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CommonDataVerify {

	public static boolean isColor(String color) {
		if (TextUtils.isEmpty(color))
			return false ;
		String reg = "^#[0-9a-fA-F]{6}$" ;
		Pattern p = Pattern.compile(reg) ;
		Matcher m = p.matcher(color) ;
		return m.find() ;
	}

	public static boolean isMobilePhoneNo(String mobile) {
		if (TextUtils.isEmpty(mobile))
			return false ;
		String reg = "^1[345678]{1}[0-9]{9}$" ;
		Pattern p = Pattern.compile(reg) ;
		Matcher m = p.matcher(mobile) ;
		return m.find() ;
	}
	   
	public static boolean isEmail(String strEmail) 
	{ 
		if (TextUtils.isEmpty(strEmail))
			return false ;
		String strPattern = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"; 
		Pattern p = Pattern.compile(strPattern); 
		Matcher m = p.matcher(strEmail); 
		return m.matches(); 
	} 
	
	
	/**
	 * 在a-zA-Z_中是否含有中文
	 * @param text
	 * @return
	 */
	public static boolean isChineseText(String text){
		if (TextUtils.isEmpty(text)) {
			return false ;
		}
		String strPattern = "\\w*[\\u4E00-\\u9FA5\\uF900-\\uFA2D]+\\w*";
		Pattern p = Pattern.compile(strPattern); 
		Matcher m = p.matcher(text); 
		return m.matches(); 
	}
	
	/**
	 * 昵称匹配，数字0-9英文大小字母，下划线，中文
	 * @param text
	 * @return
	 */
	public static boolean isNickName(String text){
		if (TextUtils.isEmpty(text)) {
			return false ;
		}
		String strPattern = "[0-9a-zA-Z_\\u4E00-\\u9FA5\\uF900-\\uFA2D]+";
		Pattern p = Pattern.compile(strPattern); 
		Matcher m = p.matcher(text); 
		return m.matches(); 
	}

	/**
	 * 匹配，数字0-9
	 * @param text
	 * @return
	 */
	public static boolean isNumember(String text){
		if (TextUtils.isEmpty(text)) {
			return false ;
		}
		String strPattern = "[0-9]+";
		Pattern p = Pattern.compile(strPattern);
		Matcher m = p.matcher(text);
		return m.matches();
	}
	
	/**
	 * 4-20个字符，只能使用小写字母(a-z)、数字(0-9)、下划线(_)、中划线(-)，且以字母或数字开头和结尾
	 * @param text
	 * @return
	 */
	public static boolean isAccountText(String text){
		if (TextUtils.isEmpty(text)) {
			return false ;
		}
		String strPattern = "^([0-9a-z]{1}[0-9a-z-_]+[0-9a-z]{1})$";
		Pattern p = Pattern.compile(strPattern); 
		Matcher m = p.matcher(text); 
		return m.matches(); 
	}
	
	
	public static boolean isBlankSpace(String text){
		if (TextUtils.isEmpty(text)) {
			return false ;
		}
		if (text.replace(" ", "").equals(text)) {
			return false;
		}
		else {
			return true;
		}
	}
}
